package com.woniuxy.yoga.order.web.controller;


import cn.hutool.core.bean.BeanUtil;
import com.woniuxy.yoga.commons.core.model.PageInfo;
import com.woniuxy.yoga.commons.core.model.Result;
import com.woniuxy.yoga.commons.web.log.YogaLog;
import com.woniuxy.yoga.order.model.form.ListOrderLogForm;
import com.woniuxy.yoga.order.model.form.SelectOrderLogForm;
import com.woniuxy.yoga.order.model.param.ListOrderLogParam;
import com.woniuxy.yoga.order.model.param.SelectOrderLogParam;
import com.woniuxy.yoga.order.service.OrderLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 * 订单日志表 前端控制器
 * </p>
 *
 * @author 韦用文,刘存益,郎腾霄
 * @since 2023年12月05日
 */
@RestController
@RequestMapping("/orderLog")
@Api(tags = "订单日志管理")
public class OrderLogController {

    @Autowired
    private OrderLogService orderLogService;

    /**
     * 分页查看订单日志
     * @param form 分页查看订单日志参数
     * @return 分页数据
     */
    @PostMapping("/listOrderLog.api")
    @ApiOperation("分页查看订单日志")
    @YogaLog("分页查看订单日志")
    public Result<PageInfo> listOrderLog(@RequestBody @Valid ListOrderLogForm form){
        PageInfo pageInfo = orderLogService.listOrderLog(BeanUtil.toBean(form, ListOrderLogParam.class));
        return Result.getResult(PageInfo.class).setMessage("查询订单日志成功").setData(pageInfo);
    }

    /**
     * 商家分页查看订单日志
     * @param form 分页查看订单日志参数
     * @return 分页数据
     */
    @PostMapping("/selectOrderLog.bu")
    @ApiOperation("商家分页查看订单日志")
    @YogaLog("商家分页查看订单日志")
    public Result<PageInfo> selectOrderLog(@RequestBody @Valid SelectOrderLogForm form){
        PageInfo pageInfo = orderLogService.selectOrderLog(BeanUtil.toBean(form, SelectOrderLogParam.class));
        return Result.getResult(PageInfo.class).setMessage("查询订单日志成功").setData(pageInfo);
    }
}

